<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\UserCoupon;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class UserCouponController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new UserCoupon(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('user_id');
            $grid->column('coupon_id');
            $grid->column('mode');
            $grid->column('title');
            $grid->column('range');
            $grid->column('full_price');
            $grid->column('price');
            $grid->column('shop_id');
            $grid->column('cid');
            $grid->column('good_id');
            $grid->column('service_id');
            $grid->column('areas');
            $grid->column('start_time');
            $grid->column('status');
            $grid->column('used_time');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
        
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new UserCoupon(), function (Show $show) {
            $show->field('id');
            $show->field('user_id');
            $show->field('coupon_id');
            $show->field('mode');
            $show->field('title');
            $show->field('range');
            $show->field('full_price');
            $show->field('price');
            $show->field('shop_id');
            $show->field('cid');
            $show->field('good_id');
            $show->field('service_id');
            $show->field('areas');
            $show->field('start_time');
            $show->field('status');
            $show->field('used_time');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new UserCoupon(), function (Form $form) {
            $form->display('id');
            $form->text('user_id');
            $form->text('coupon_id');
            $form->text('mode');
            $form->text('title');
            $form->text('range');
            $form->text('full_price');
            $form->text('price');
            $form->text('shop_id');
            $form->text('cid');
            $form->text('good_id');
            $form->text('service_id');
            $form->text('areas');
            $form->text('start_time');
            $form->text('status');
            $form->text('used_time');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
